package com.hhit.bigscreenbackmanage.service.impl.jsgl;


import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.PageUtil;
import com.hhit.bigscreenbackmanage.dao.jsgl.JsglMapper;
import com.hhit.bigscreenbackmanage.dao.jsgl.TJsglTysbyyMapper;
import com.hhit.bigscreenbackmanage.dao.jsgl.TJsglTysjBdzMapper;
import com.hhit.bigscreenbackmanage.entity.jsgl.*;
import com.hhit.bigscreenbackmanage.service.jsgl.JsglService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class JsglServiceImpl implements JsglService {

    private static final Logger logger = LoggerFactory.getLogger(JsglServiceImpl.class);

    @Resource
    private JsglMapper jsglMapper;

    @Autowired
    TJsglTysjBdzMapper tJsglTysjBdzMapper;

    @Autowired
    TJsglTysbyyMapper tJsglTysbyyMapper;

    /**
     * 获取变电站通用设计应用率
     *
     * @param map
     * @return page
     */
    @Override
    public TysjBdzEntity getbdztysjNum(Map map) {
        if("建设分公司".equals(map.get("sjdw"))){
            map.put("sjdw", "");
            map.put("sjdw2", "建设分公司");
        }
        List<TysjBdzEntity> list = jsglMapper.getbdztysjNum(map);
        if(list.size()>0){
            if(list.get(0) == null){
                return new TysjBdzEntity();
            }else {
                return list.get(0);
            }
        }else {
            return new TysjBdzEntity();
        }
    }

    /**
     * 获取变电站通用设计应用率
     *
     * @param map
     * @return page
     */
    @Override
    public PageUtil<TysjBdzEntity> getbdztysj(Map map) {
        PageUtil<TysjBdzEntity> page = new PageUtil<>();
        try {
            if("建设分公司".equals(map.get("sjdw"))){
                map.put("sjdw", "");
                map.put("sjdw2", "建设分公司");
            }
            page.pageCount=Integer.parseInt(map.get("PAGESIZE").toString());
            page.init(jsglMapper.getbdztysjCount(map),Integer.parseInt(map.get("PAGENO").toString()));//参数1：总行数，参数2：当前页
            map.put("rowNum",page.getRowNum());//当前页起始行号
            map.put("pageCount",Integer.parseInt(map.get("PAGESIZE").toString()));//每页行数
            List<TysjBdzEntity> list = jsglMapper.getbdztysj(map);
            page.setList(list);
            List<Map<String, Object>> list2 = jsglMapper.getbdztysjChartNum(map);
            map.put("sjdw", "");
            map.put("sjdw2", "建设分公司");
            String jsfgs = jsglMapper.getbdztysjCount(map).toString();
            page.setChartList(Arrays.asList(returnChartArr(list2, jsfgs)));
        } catch (Exception e) {
            logger.error("获取变电站通用设计应用率报错啦：" + e.getMessage());
        }
        return page;
    }

    /**
     * 返回中间柱状图数组
     * @return
     */
    public String[] returnChartArr(List<Map<String, Object>> list, String jsfgs){
        String[] chartArr = new String[14];
        chartArr[0] = jsfgs;
        for(Map<String, Object> map1:list){
            chartArr[1] = map1.get("njzsl").toString();
            chartArr[2] = map1.get("szzsl").toString();
            chartArr[3] = map1.get("wxzsl").toString();
            chartArr[4] = map1.get("xzzsl").toString();
            chartArr[5] = map1.get("czzsl").toString();
            chartArr[6] = map1.get("zjzsl").toString();
            chartArr[7] = map1.get("yzzsl").toString();
            chartArr[8] = map1.get("tzzsl").toString();
            chartArr[9] = map1.get("ntzsl").toString();
            chartArr[10] = map1.get("yczsl").toString();
            chartArr[11] = map1.get("hazsl").toString();
            chartArr[12] = map1.get("sqzsl").toString();
            chartArr[13] = map1.get("lygzsl").toString();
        }
        return chartArr;
    }

    /**
     * 获取线路通用设计
     *
     * @param map
     * @return page
     */
    @Override
    public PageUtil<TysjXlEntity> getTysjXl(Map map) {
        PageUtil<TysjXlEntity> page = new PageUtil<>();
        try {
            if("建设分公司".equals(map.get("sjdw"))){
                map.put("sjdw", "");
                map.put("sjdw2", "建设分公司");
            }
            page.pageCount=Integer.parseInt(map.get("PAGESIZE").toString());
            page.init(jsglMapper.getTysjXlCount(map),Integer.parseInt(map.get("PAGENO").toString()));//参数1：总行数，参数2：当前页
            map.put("rowNum",page.getRowNum());//当前页起始行号
            map.put("pageCount",Integer.parseInt(map.get("PAGESIZE").toString()));//每页行数
            List<TysjXlEntity> list = jsglMapper.getTysjXl(map);
            page.setList(list);
            map.put("sjdw", "");
            map.put("sjdw2", "建设分公司");
            String jsfgs = jsglMapper.getTysjXlCount(map).toString();
            List<Map<String, Object>> list2 = jsglMapper.getTysjXlChartNum();
            page.setChartList(Arrays.asList(returnChartArr(list2, jsfgs)));
        } catch (Exception e) {
            logger.error("获取线路通用设计报错啦：" + e.getMessage());
        }
        return page;
    }

    /**
     * 获取通用设备应用
     *
     * @param map
     * @return page
     */
    @Override
    public PageUtil<TysjSbyylEntity> getTysbyy(Map map) {
        PageUtil<TysjSbyylEntity> page = new PageUtil<>();
        try {
            if("建设分公司".equals(map.get("sjdw"))){
                map.put("sjdw", "");
                map.put("sjdw2", "建设分公司");
            }
            page.pageCount=Integer.parseInt(map.get("PAGESIZE").toString());
            page.init(jsglMapper.getTysbyyCount(map),Integer.parseInt(map.get("PAGENO").toString()));//参数1：总行数，参数2：当前页
            map.put("rowNum",page.getRowNum());//当前页起始行号
            map.put("pageCount",Integer.parseInt(map.get("PAGESIZE").toString()));//每页行数
            List<TysjSbyylEntity> list = jsglMapper.getTysbyy(map);
            page.setList(list);
            map.put("sjdw", "");
            map.put("sjdw2", "建设分公司");
            String jsfgs = jsglMapper.getTysbyyCount(map).toString();
            List<Map<String, Object>> list2 = jsglMapper.getTysbyyChartNum();
            page.setChartList(Arrays.asList(returnChartArr(list2, jsfgs)));
        } catch (Exception e) {
            logger.error("获取线路通用设计报错啦：" + e.getMessage());
        }
        return page;
    }

    /**
     * 获取新技术应用统计
     *
     * @param map
     * @return list
     */
    @Override
    public XjsyyEntity getXjsyyNum(Map map) {
        List<XjsyyEntity> list = jsglMapper.getXjsyyNum(map);
        if(list.size()>0){
            if(list.get(0) == null){
                return new XjsyyEntity();
            }else {
                return list.get(0);
            }
        }else {
            return new XjsyyEntity();
        }
    }

    /**
     * 获取新技术应用中间柱状图统计
     *
     * @param map
     * @return list
     */
    @Override
    public List<String> getXjsyyChartNum(Map map) {
        List<Map<String, String>> list = jsglMapper.getXjsyyChartNum(map);
        String[] result = {"0","0","0","0","0","0","0","0","0","0","0","0","0","0"};
        if(list.size()>0){
            for(Map<String, String> map1: list){
                if("建设分公司".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[0] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[0] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[0] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[0] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[0] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[0] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[0] = String.valueOf(map1.get("zsl"));
                    }
                }else if("南京".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[1] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[1] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[1] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[1] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[1] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[1] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[1] = String.valueOf(map1.get("zsl"));
                    }
                }else if("苏州".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[2] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[2] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[2] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[2] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[2] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[2] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[2] = String.valueOf(map1.get("zsl"));
                    }
                }else if("无锡".equals(map1.get("jgdw"))){
                    if("2".equals(map1.get("jndx"))){
                        result[3] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[3] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[3] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[3] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[3] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[3] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[3] = String.valueOf(map1.get("zsl"));
                    }
                }else if("徐州".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[4] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[4] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[4] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[4] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[4] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[4] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[4] = String.valueOf(map1.get("zsl"));
                    }
                }else if("常州".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[5] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[5] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[5] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[5] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[5] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[5] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[5] = String.valueOf(map1.get("zsl"));
                    }
                }else if("镇江".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[6] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[6] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[6] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[6] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[6] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[6] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[6] = String.valueOf(map1.get("zsl"));
                    }
                }else if("扬州".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[7] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[7] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[7] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[7] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[7] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[7] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[7] = String.valueOf(map1.get("zsl"));
                    }
                }else if("泰州".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[8] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[8] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[8] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[8] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[8] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[8] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[8] = String.valueOf(map1.get("zsl"));
                    }
                }else if("南通".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[9] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[9] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[9] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[9] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[9] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[9] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[9] = String.valueOf(map1.get("zsl"));
                    }
                }else if("盐城".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[10] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[10] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[10] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[10] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[10] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[10] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[10] = String.valueOf(map1.get("zsl"));
                    }
                }else if("淮安".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[11] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[11] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[11] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[11] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[11] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[11] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[11] = String.valueOf(map1.get("zsl"));
                    }
                }else if("宿迁".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[12] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[12] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[12] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[12] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[12] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[12] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[12] = String.valueOf(map1.get("zsl"));
                    }
                }else if("连云港".equals(map1.get("jgdw"))){
                    if("2".equals(map.get("jndx"))){
                        result[13] = String.valueOf(map1.get("jndxzsl"));
                    }else if("3".equals(map.get("jd"))){
                        result[13] = String.valueOf(map1.get("jdzsl"));
                    }else if("4".equals(map.get("qsj"))){
                        result[13] = String.valueOf(map1.get("qsjzsl"));
                    }else if("5".equals(map.get("gt"))){
                        result[13] = String.valueOf(map1.get("gtzsl"));
                    }else if("6".equals(map.get("yzc"))){
                        result[13] = String.valueOf(map1.get("yzczsl"));
                    }else if("7".equals(map.get("wqb"))){
                        result[13] = String.valueOf(map1.get("wqbzsl"));
                    }else {
                        result[13] = String.valueOf(map1.get("zsl"));
                    }
                }
            }
        }
        return Arrays.asList(result);
    }

    /**
     * 获取新技术应用
     *
     * @param map
     * @return page
     */
    @Override
    public PageUtil<XjsyyEntity> getXjsyy(Map map) {
        PageUtil<XjsyyEntity> page = new PageUtil<>();
        try {
            page.pageCount=Integer.parseInt(map.get("PAGESIZE").toString());
            page.init(jsglMapper.getXjsyyCount(map),Integer.parseInt(map.get("PAGENO").toString()));//参数1：总行数，参数2：当前页
            map.put("rowNum",page.getRowNum());//当前页起始行号
            map.put("pageCount",Integer.parseInt(map.get("PAGESIZE").toString()));//每页行数
            List<XjsyyEntity> list = jsglMapper.getXjsyy(map);
            page.setList(list);
        } catch (Exception e) {
            logger.error("获取新技术应用报错啦：" + e.getMessage());
        }
        return page;
    }

    /**
     * 获取三维成果应用统计
     *
     * @param map
     * @return page
     */
    @Override
    public SwccyyEntity getSwcgyyNum(Map map) {
        List<SwccyyEntity> list = jsglMapper.getSwcgyyNum(map);
        if(list.size()>0){
            if(list.get(0) == null){
                return new SwccyyEntity();
            }else {
                return list.get(0);
            }
        }else {
            return new SwccyyEntity();
        }
    }

    /**
     * 获取三维成果应用中间柱状图统计
     *
     * @param map
     * @return list
     */
    @Override
    public List<String> getSwcgyyChartNum(Map map) {
        List<Map<String, String>> list = jsglMapper.getSwcgyyChartNum(map);
        return returnList(list);
    }

    /**
     * 获取三维成果应用
     *
     * @param map
     * @return page
     */
    @Override
    public PageUtil<SwccyyEntity> getSwcgyy(Map map) {
        PageUtil<SwccyyEntity> page = new PageUtil<>();
        try {
            page.pageCount=Integer.parseInt(map.get("PAGESIZE").toString());
            page.init(jsglMapper.getSwcgyyCount(map),Integer.parseInt(map.get("PAGENO").toString()));//参数1：总行数，参数2：当前页
            map.put("rowNum",page.getRowNum());//当前页起始行号
            map.put("pageCount",Integer.parseInt(map.get("PAGESIZE").toString()));//每页行数
            List<SwccyyEntity> list = jsglMapper.getSwcgyy(map);
            page.setList(list);
        } catch (Exception e) {
            logger.error("获取新技术应用报错啦：" + e.getMessage());
        }
        return page;
    }

    /**
     * 获取设计质量问题统计
     *
     * @param map
     * @return page
     */
    @Override
    public SjzlwtEntity getSjzlwtNum(Map map) {
        if("建设分公司".equals(map.get("sjdw"))){
            map.put("sjdw", "");
            map.put("sjdw2", "建设分公司");
        }
        List<SjzlwtEntity> list = jsglMapper.getSjzlwtNum(map);
        if(list.size()>0){
            if(list.get(0) == null){
                return new SjzlwtEntity();
            }else {
                return list.get(0);
            }
        }else {
            return new SjzlwtEntity();
        }
    }

    /**
     * 获取设计质量问题
     *
     * @param map
     * @return page
     */
    @Override
    public PageUtil<SjzlwtEntity> getSjzlwt(Map map) {
        PageUtil<SjzlwtEntity> page = new PageUtil<>();
        try {
            if("建设分公司".equals(map.get("sjdw"))){
                map.put("sjdw", "");
                map.put("sjdw2", "建设分公司");
            }
            page.pageCount=Integer.parseInt(map.get("PAGESIZE").toString());
            page.init(jsglMapper.getSjzlwtCount(map),Integer.parseInt(map.get("PAGENO").toString()));//参数1：总行数，参数2：当前页
            map.put("rowNum",page.getRowNum());//当前页起始行号
            map.put("pageCount",Integer.parseInt(map.get("PAGESIZE").toString()));//每页行数
            List<SjzlwtEntity> list = jsglMapper.getSjzlwt(map);
            page.setList(list);
            List<Map<String, Object>> list2 = jsglMapper.getSjzlwtChartNum(map);
            map.put("sjdw", "");
            map.put("sjdw2", "建设分公司");
            String jsfgs = jsglMapper.getSjzlwtCount(map).toString();
            page.setChartList(Arrays.asList(returnChartArr(list2, jsfgs)));
        } catch (Exception e) {
            logger.error("获取新技术应用报错啦：" + e.getMessage());
        }
        return page;
    }

    /**
     * 获取设计变更
     *
     * @param map
     * @return page
     */
    @Override
    public PageUtil<SjbgEntity> getSjbg(Map map) {
        PageUtil<SjbgEntity> page = new PageUtil<>();
        try {
            if("建设分公司".equals(map.get("sjdw"))){
                map.put("sjdw", "");
                map.put("sjdw2", "建设分公司");
            }
            page.pageCount=Integer.parseInt(map.get("PAGESIZE").toString());
            page.init(jsglMapper.getSjbgCount(map),Integer.parseInt(map.get("PAGENO").toString()));//参数1：总行数，参数2：当前页
            map.put("rowNum",page.getRowNum());//当前页起始行号
            map.put("pageCount",Integer.parseInt(map.get("PAGESIZE").toString()));//每页行数
            List<SjbgEntity> list = jsglMapper.getSjbg(map);
            page.setList(list);
            List<Map<String, Object>> list2 = jsglMapper.getSjbgChartNum(map);
            map.put("sjdw", "");
            map.put("sjdw2", "建设分公司");
            String jsfgs = jsglMapper.getSjbgCount(map).toString();
            page.setChartList(Arrays.asList(returnChartArr(list2, jsfgs)));
        } catch (Exception e) {
            logger.error("获取新技术应用报错啦：" + e.getMessage());
        }
        return page;
    }

    /**
     * 获取设计变更统计
     *
     * @param map
     * @return list
     */
    @Override
    public SjbgEntity getSjbgNum(Map map) {
        if("建设分公司".equals(map.get("sjdw"))){
            map.put("sjdw", "");
            map.put("sjdw2", "建设分公司");
        }
        List<SjbgEntity> list = jsglMapper.getSjbgNum(map);
        if(list.size()>0){
            if(list.get(0) == null){
                return new SjbgEntity();
            }else {
                return list.get(0);
            }
        }else {
            return new SjbgEntity();
        }
    }

    public List<String> returnList(List<Map<String, String>> list){
        String[] result = new String[14];
        if(list.size()>0){
            for(Map<String, String> map1: list){
                if("建设分公司".equals(map1.get("jgdw"))){
                    result[0] = String.valueOf(map1.get("zsl"));
                }else if("南京".equals(map1.get("jgdw"))){
                    result[1] = String.valueOf(map1.get("zsl"));
                }else if("苏州".equals(map1.get("jgdw"))){
                    result[2] = String.valueOf(map1.get("zsl"));
                }else if("无锡".equals(map1.get("jgdw"))){
                    result[3] = String.valueOf(map1.get("zsl"));
                }else if("徐州".equals(map1.get("jgdw"))){
                    result[4] = String.valueOf(map1.get("zsl"));
                }else if("常州".equals(map1.get("jgdw"))){
                    result[5] = String.valueOf(map1.get("zsl"));
                }else if("镇江".equals(map1.get("jgdw"))){
                    result[6] = String.valueOf(map1.get("zsl"));
                }else if("扬州".equals(map1.get("jgdw"))){
                    result[7] = String.valueOf(map1.get("zsl"));
                }else if("泰州".equals(map1.get("jgdw"))){
                    result[8] = String.valueOf(map1.get("zsl"));
                }else if("南通".equals(map1.get("jgdw"))){
                    result[9] = String.valueOf(map1.get("zsl"));
                }else if("盐城".equals(map1.get("jgdw"))){
                    result[10] = String.valueOf(map1.get("zsl"));
                }else if("淮安".equals(map1.get("jgdw"))){
                    result[11] = String.valueOf(map1.get("zsl"));
                }else if("宿迁".equals(map1.get("jgdw"))){
                    result[12] = String.valueOf(map1.get("zsl"));
                }else if("连云港".equals(map1.get("jgdw"))){
                    result[13] = String.valueOf(map1.get("zsl"));
                }
            }
        }
        return Arrays.asList(result);
    }

    @Override
    public Integer getSjzlwtsjCount(Map map) {
        logger.info("start to get count");
        Integer count = jsglMapper.getSjzlwtsjCount();

        logger.info("count is {}", count);
        return count;
    }

    @Override
    public PageUtil<SjzlwtEntity> getSjzlwtsj(Map map) {
        logger.info("start to get warn detail");
        PageUtil<SjzlwtEntity> page = new PageUtil<SjzlwtEntity>();

        Integer pagesize = Integer.parseInt(map.get("PAGESIZE").toString());
        Integer pageno = Integer.parseInt(map.get("PAGENO").toString());

        page.pageCount = pagesize;
        //参数1：总行数，参数2：当前页
        page.init(jsglMapper.getSjzlwtsjCount(), pageno);
        //当前页起始行号
        map.put("rowNum", page.getRowNum());
        //每页行数
        map.put("pageCount", pagesize);

        List<SjzlwtEntity> details = jsglMapper.getSjzlwtsj(map);
        page.setList(details);
        logger.info("detail is {}", details.toString());
        return page;
    }

    @Override
    public Map<String, String> queryCgyyCount(JSONObject jsonObject) throws Exception {

        Map<String, String> result = new HashMap<>();

        try{
            result = jsglMapper.queryCgyyCount(jsonObject);
        }catch (Exception e){
            logger.error(e.getMessage());
            throw new Exception("数据库内部错误");
        }

        String dataTime = tJsglTysjBdzMapper.queryTysjBdzMaxDataTime();
        jsonObject.put("dataTime",dataTime);
        Integer tyyysj1 = tJsglTysjBdzMapper.queryTysjBdzCount(jsonObject);
        jsonObject.put("tyyysjl","true");
        Integer tyyysj2 = tJsglTysjBdzMapper.queryTysjBdzCount(jsonObject);
        Double tyyysjl = Double.valueOf(0);
        if(tyyysj1 != 0) {
            tyyysjl = new BigDecimal((float) tyyysj2 / tyyysj1 * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        }

        dataTime = tJsglTysbyyMapper.queryTysbyyMaxDataTime();
        jsonObject.put("dataTime",dataTime);
        Integer tysbyy1 = tJsglTysbyyMapper.queryTysbyyNum(jsonObject);
        jsonObject.put("tysbyyl","true");
        Integer tysbyy2 = tJsglTysbyyMapper.queryTysbyyNum(jsonObject);
        Double tysbyyl = Double.valueOf(0);
        if(tysbyy1 != 0) {
            tysbyyl = new BigDecimal((float) tysbyy2 / tysbyy1 * 100).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
        }

        result.put("tyyysjl",String.valueOf(tyyysjl));
        result.put("tysbyyl",String.valueOf(tysbyyl));

        return result;
    }
}
